/*
 * 作者：姚俊
 * 功能：从服务器下载文件的action
 * 日期：2015-05-24
 */
package admin.action.baseInfo;

import java.io.InputStream;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.*;

@SuppressWarnings("serial")
public class FileDownloadAction
	extends ActionSupport
{
	private String inputPath;

	public void setInputPath(String value)
	{
		inputPath = value;
	}

	public InputStream getTargetFile() throws Exception
	{
//		new Timer(2000, null);
//		Thread.currentThread().sleep(3000);
//		new Thread()
//		{
//			
//
//			if(inputPath==null||inputPath.equals(""))
//				
//					this.setInputPath(ActionContext.getContext().get("inputpath").toString());
//				
//			
//			
//		};


		
		if(inputPath==null||inputPath.equals(""))
		{
			this.setInputPath(ActionContext.getContext().get("inputpath").toString());
		}
		
		System.out.println("路径为:"+this.inputPath);

		return ServletActionContext.getServletContext()
			.getResourceAsStream(inputPath);
	}
}
